function spanLogin() {
    if($("#customerorboss2_a").text()=="邮箱登录"){
        $("#customerorboss2_a").text("密码登录");
        $(".loginbutton ").css("display","none");
        $("#loginButtonBoxBox").css("display","block");
        $(".userform").attr("placeholder","    邮箱")
        $(".pwdform").attr("placeholder","    验证码")
    }else {
        $("#customerorboss2_a").text("邮箱登录");
        $(".loginbutton ").css("display","block");
        $("#loginButtonBoxBox").css("display","none");
        $(".userform").attr("placeholder","    账户")
        $(".pwdform").attr("placeholder","    密码")
    }
}

function sendCode(){
   let email=$(".userform").val();
    $.get('/dev/login/sendcode?email='+email,function(result){
        if(result.code=="BAD"){
            alert(result.msg);
        }else{
            alert("发送成功:"+result.data)
        }
    })

}

function emailLogin(){
    console.log("eqeqweqweq")
    let email = $(".userform").val();
    let code=$(".pwdform").val();
    $.post('/dev/login/emaillogin?email='+email+"&code="+code,function(result){
        if(result.code=='BAD'){
            alert(result.msg);
        }else if(result.code=='EXPIRED'){
            alert(result.msg);
        }else if(result.code=='WRONG'){
            alert(result.msg);
        }
        else{
            //将server返回过来的token进行一个本地存储
            localStorage.setItem("token",result.data);
            window.location.replace("/dev/index/loginto");
        }
    })

}


function customerLogin(){
    let username = $(".userform").val();
    let pwd=$(".pwdform").val();
    $.ajax({
        type:'post',
        headers:{
            'token':localStorage.getItem("token")
        },
        url:'/dev/login/accountlogin?username='+username+"&password="+pwd,
        success:function(result){
            if(result.code=='BAD'){
                alert(result.msg);
            }else if(result.code=='WRONG'){
                alert(result.msg);
            }
            else{
                //将server返回过来的token进行一个本地存储
                localStorage.setItem("token",result.data);
                    window.location.replace("/dev/index/loginto");
            }
        }
    })
    // $.post('/dev/login/accountlogin?username='+username+"&password="+pwd,function(result){
    //     if(result.code=='BAD'){
    //         alert(result.msg);
    //     }else if(result.code=='WRONG'){
    //         alert(result.msg);
    //     }
    //     else{
    //         //将server返回过来的token进行一个本地存储
    //         localStorage.setItem("token",result.data);
    //         window.location.replace("/dev/index/loginto");
    //     }
    // })
}

